<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/5/15
 * Time: 16:06
 */

namespace backend\controllers;


use common\controllers\BackendCommonCtrl;
use common\services\WorkSve;
use common\services\WorksClassSve;
use Yii;
use common\library\comFun;
use yii\helpers\Url;

class WorkController extends BackendCommonCtrl
{
    /**
     * 列表
     * @return string
     */
    public function actionList()
    {
        $request = Yii::$app->request;


        $workClassId = $request->get('work_class_id',0);
        $memberName = $request->get('member_name',0);
        //去向
        $WorksClassSve = new WorksClassSve();
        $worksClassList = $WorksClassSve->getList(['is_show'=>1]);

        $where = [];
        if($workClassId || $memberName){
            $where = ['and'];
            if($workClassId) {
                array_push($where, ['=','work_class_id',$workClassId]);
            }
            if($memberName) {
                array_push($where, ['like','member_name',$memberName]);
            }
        }


        $WorkSve = new WorkSve();
        $rs = $WorkSve->getList($where, 'work_id DESC', true);
        return $this->render('list', ['list'=>$rs['data']['list'] ,'pageArr'=>$rs['data']['pageArr'] ,'workClassList'=>$worksClassList['data']['list'],'workClassId'=>$workClassId]);
    }

    /**
     * 添加
     * @return string
     */
    public function actionAdd()
    {
        return $this->render('edit', ['info' => []]);
    }

}